<template>
  <a-card :bordered="false">
    <!-- 查询区域 --> 
    <div class="table-page-search-wrapper">
      <a-form layout="inline" @keyup.enter.native="searchQuery">
        <a-row :gutter="24">
          <a-col :xl="6" :lg="7" :md="8" :sm="24" >
            <a-form-item   label="姓　　名">

              <a-input placeholder="请输入姓名" v-model="queryParam.xm"></a-input>
            </a-form-item>
          </a-col>
          <a-col :xl="6" :lg="7" :md="8" :sm="24" >
            <a-form-item   label="状　　态">
                <a-select  v-model="queryParam.zt" placeholder="请选择"   default-value="已归档"  >
                  <a-select-option value="已归档">已归档</a-select-option>   
                  <a-select-option value="已调档">已调档</a-select-option>   
                  <a-select-option value="未归档">未归档</a-select-option>           
                </a-select> 
            </a-form-item>
          </a-col>
          <template v-if="toggleSearchStatus">
            <a-col :xl="6" :lg="7" :md="8" :sm="24" >
              <a-form-item label="身份证号">
                
                <a-input placeholder="请输入身份证号" v-model="queryParam.sfzh"></a-input>
              </a-form-item>
            </a-col>
            <a-col :xl="6" :lg="7" :md="8" :sm="24" >
              <a-form-item label="性　　别">
                <j-dict-select-tag
                  type="list"
                  v-model="queryParam.xb"
                  dictCode="xb"
                  placeholder="请选择性别"
                />
              </a-form-item>
            </a-col>
          
            <a-col :xl="6" :lg="7" :md="8" :sm="24">
              <a-form-item label="出生日期">
                <a-range-picker @change="onCsrqChange" v-model="queryParam.csrq"/>
              </a-form-item>
            </a-col>
            <a-col :xl="6" :lg="7" :md="8" :sm="24">
              <a-form-item label="民　　族">
                <j-dict-select-tag
                  type="list"
                  v-model="queryParam.mz"
                  dictCode="mz"
                  placeholder="请选择民族"
                />
              </a-form-item>
            </a-col>
            <a-col :xl="6" :lg="7" :md="8" :sm="24">
              <a-form-item label="入伍时间">
                <a-range-picker @change="onRwsjChange" v-model="queryParam.rwsj"/>
              </a-form-item>
            </a-col>
            <a-col :xl="6" :lg="7" :md="8" :sm="24">
              <a-form-item label="退伍时间">
                <a-range-picker @change="onTwsjChange"  v-model="queryParam.twsj"/>
              </a-form-item>
            </a-col>
            <a-col :xl="6" :lg="7" :md="8" :sm="24">
              <a-form-item label="政治面貌">
                <j-dict-select-tag
                  type="list"
                  v-model="queryParam.zzmm"
                  dictCode="zzmm"
                  placeholder="请选择政治面貌"
                />
              </a-form-item>
            </a-col>
            <a-col :xl="6" :lg="7" :md="8" :sm="24">
              <a-form-item label="联系电话">
                <a-input placeholder="请输入线索描述" v-model="queryParam.lxdh"></a-input>
              </a-form-item>
            </a-col>
            <a-col :xl="6" :lg="7" :md="8" :sm="24">
              <a-form-item label="学历情况">
                <a-input placeholder="请输入线索描述" v-model="queryParam.xlqk"></a-input>
              </a-form-item>
            </a-col>
            <a-col :xl="6" :lg="7" :md="8" :sm="24">
              <a-form-item label="健康状况">
                <j-dict-select-tag
                  type="list"
                  v-model="queryParam.jkzt"
                  dictCode="jkzk"
                  placeholder="请选择健康状态"
                />
              </a-form-item>
            </a-col>
            <a-col :xl="6" :lg="7" :md="8" :sm="24">
              <a-form-item label="残疾性质">
                <j-dict-select-tag
                  type="list"
                  v-model="queryParam.cjxz"
                  dictCode="cjxz"
                  placeholder="请选择残疾性质"
                />
              </a-form-item>
            </a-col>
            <a-col :xl="6" :lg="7" :md="8" :sm="24">
              <a-form-item label="部队代号">
                <a-input placeholder="请输入线索描述" v-model="queryParam.bddh"></a-input>
              </a-form-item>
            </a-col>
            <a-col :xl="6" :lg="7" :md="8" :sm="24">
              <a-form-item label="退伍证号">
                <a-input placeholder="请输入线索描述" v-model="queryParam.twzh"></a-input>
              </a-form-item>
            </a-col>
            <a-col :xl="6" :lg="7" :md="8" :sm="24">
              <a-form-item label="安置方式">
                <j-dict-select-tag
                  type="list"
                  v-model="queryParam.azfs"
                  dictCode="azfs"
                  placeholder="请选择安置方式"
                />
              </a-form-item>
            </a-col> 
            <a-col :xl="6" :lg="7" :md="8" :sm="24">
              <a-form-item label="军　　龄">
                <a-input placeholder="请输入线索描述" v-model="queryParam.jl"></a-input>
              </a-form-item>
            </a-col>
            <a-col :xl="6" :lg="7" :md="8" :sm="24">
              <a-form-item label="入伍高校">
                <a-input placeholder="请输入线索描述" v-model="queryParam.rwgxmc"></a-input>
              </a-form-item>
            </a-col>
          </template>
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <span style="float: left;overflow: hidden;" class="table-page-search-submitButtons">
              <a-button type="primary" @click="searchQuery" icon="search">查询</a-button>
              <a-button type="primary" @click="searchReset" icon="reload" style="margin-left: 8px">重置</a-button> 
              <a @click="handleToggleSearch" style="margin-left: 8px">
                {{ toggleSearchStatus ? '收起' : '展开' }}
                <a-icon :type="toggleSearchStatus ? 'up' : 'down'"/>
              </a>
            </span>
          </a-col>
        </a-row>
      </a-form>
    </div>
    <!-- 查询区域-END -->

    <!-- 操作按钮区域 -->
    <!-- <div class="table-operator">
      <a-button type="primary" @click="searchQuery" icon="search">刷新</a-button>
      <a-button @click="handleAdd" type="primary" icon="plus">新增</a-button>
      <a-button type="primary" icon="download" @click="handleExportXls('人员档案信息表')">导出</a-button> -->
      <!-- <a-upload name="file" :showUploadList="false" :multiple="false" :headers="tokenHeader" :action="importExcelUrl" @change="handleImportExcel">
        <a-button type="primary" icon="import">导入</a-button>
      </a-upload> -->
      <!-- 高级查询区域 -->
      <!-- <j-super-query :fieldList="superFieldList" ref="superQueryModal" @handleSuperQuery="handleSuperQuery"></j-super-query> -->
      <!-- <a-dropdown v-if="selectedRowKeys.length > 0">
        <a-menu slot="overlay">
          <a-menu-item key="1" @click="batchDel"><a-icon type="delete"/>删除</a-menu-item>
        </a-menu>
        <a-button style="margin-left: 8px"> 批量操作 <a-icon type="down" /></a-button>
      </a-dropdown> -->
    <!-- </div> -->

    <!-- table区域-begin -->
    <div ref="page">
      <!-- <div class="ant-alert ant-alert-info" style="margin-bottom: 16px;">
        <i class="anticon anticon-info-circle ant-alert-icon"></i> 已选择 <a style="font-weight: 600">{{ selectedRowKeys.length }}</a>项
        <a style="margin-left: 24px" @click="onClearSelected">清空</a>
      </div> -->

      <a-table
        ref="table"
        size="middle"
        :scroll="{x:true}"
        bordered
        rowKey="id"
        :columns="columns"
        :dataSource="dataSource"
        :pagination="ipagination"
        :loading="loading"
        class="j-table-force-nowrap"
        @change="handleTableChange">

        <template slot="htmlSlot" slot-scope="text">
          <div v-html="text"></div>
        </template>
        <template slot="imgSlot" slot-scope="text,record">
          <span v-if="!text" style="font-size: 12px;font-style: italic;">无图片</span>
          <img v-else :src="getImgView(text)" :preview="record.id" height="25px" alt="" style="max-width:80px;font-size: 12px;font-style: italic;"/>
        </template>
        <template slot="fileSlot" slot-scope="text">
          <span v-if="!text" style="font-size: 12px;font-style: italic;">无文件</span>
          <a-button
            v-else
            :ghost="true"
            type="primary"
            icon="download"
            size="small"
            @click="downloadFile(text)">
            下载
          </a-button>
        </template>

        <span slot="action" slot-scope="text, record"> 
          <a @click="handleDaAn(record)" v-if="record.zt != '已调档'">档案</a>

          <a-divider type="vertical"  v-if="record.zt != '已调档'"/>
          <a @click="handleDetail(record)" v-if="record.zt != '已调档'">详情</a> 
         
        </span>

      </a-table>
      <div style="    margin-top: -40px;color:#1890FF;">合计:{{ipagination.total}}人</div>
    </div>

    <da-ryxx-modal ref="modalForm" @ok="modalFormOk"></da-ryxx-modal>
  </a-card>
</template>

<script>

  import '@/assets/less/TableExpand.less'
  import { mixinDevice } from '@/utils/mixin'
  import { JeecgListMixin } from '@/mixins/JeecgListMixin'
  import DaRyxxModal from './modules/DaRyxxModal'
  import store from '@/store/'
  import Watermark from '@/utils/watermark'
  import { httpAction, getAction,deleteAction } from '@/api/manage' 
  export default {
    name: 'DaRyxxList',
    mixins:[JeecgListMixin, mixinDevice],
    components: {
      DaRyxxModal
    },
    data () {
      return {
        description: '人员档案信息表管理页面',
        ipagination:{
          current: 1,
          pageSize: 10,
          pageSizeOptions: ['10', '20', '30'],
          showTotal: (total, range) => {
            return range[0] + "-" + range[1] + " 共" + total + "人"
          },
          showQuickJumper: true,
          showSizeChanger: true,
          total: 0
        },
        // 表头
        columns: [
          // {
          //   title: '#',
          //   dataIndex: '',
          //   key:'rowIndex',
          //   width:60,
          //   align:"center",
          //   customRender:function (t,r,index) {
          //     return parseInt(index)+1;
          //   }
          // },
          {
            title:'姓名',
            align:"center",
            dataIndex: 'xm'
          },
          {
            title:'身份证号',
            align:"center",
            dataIndex: 'sfzh'
          },
          {
            title:'性别',
            align:"center",
            dataIndex: 'xb_dictText'
          },
          {
            title:'出生年月',
            align:"center",
            dataIndex: 'csny'
          },
          {
            title:'民族',
            align:"center",
            dataIndex: 'mz_dictText'
          },
          {
            title:'入伍时间',
            align:"center",
            dataIndex: 'rwsj',
            customRender:function (text) {
              return !text?"":(text.length>10?text.substr(0,10):text)
            }
          },
          {
            title:'退伍时间',
            align:"center",
            dataIndex: 'twsj',
            customRender:function (text) {
              return !text?"":(text.length>10?text.substr(0,10):text)
            }
          },
          {
            title:'政治面貌',
            align:"center",
            dataIndex: 'zzmm'
          },
          {
            title:'入党时间',
            align:"center",
            dataIndex: 'rdsj',
            customRender:function (text) {
              return !text?"":(text.length>10?text.substr(0,10):text)
            }
          },
          {
            title:'联系电话',
            align:"center",
            dataIndex: 'lxdh'
          },
          {
            title:'学历情况',
            align:"center",
            dataIndex: 'xlqk'
          },
          {
            title:'拟安置地',
            align:"center",
            dataIndex: 'nazd'
          },
          {
            title:'健康状态',
            align:"center",
            dataIndex: 'jkzt'
          },
          {
            title:'残疾性质',
            align:"center",
            dataIndex: 'cjxz'
          },
          {
            title:'入伍地',
            align:"center",
            dataIndex: 'rwd'
          },
          {
            title:'部队代号',
            align:"center",
            dataIndex: 'bddh'
          },
          {
            title:'退伍证号',
            align:"center",
            dataIndex: 'twzh'
          },
          {
            title:'安置方式',
            align:"center",
            dataIndex: 'azfs'
          },
          {
            title:'军龄',
            align:"center",
            dataIndex: 'jl'
          },
          {
            title:'入伍高校名称',
            align:"center",
            dataIndex: 'rwgxmc'
          },
          {
            title:'是否复学',
            align:"center",
            dataIndex: 'sffx_dictText'
          },
          {
            title:'奖惩信息',
            align:"center",
            dataIndex: 'jlxx'
          },
          {
            title:'状态',
            align:"center",
            dataIndex: 'zt'
          },
          {
            title: '操作',
            dataIndex: 'action',
            align:"center",
            fixed:"right",
            width:147,
            scopedSlots: { customRender: 'action' }
          }
        ],
        url: {
          list: "/dary/daRyxx/list",
          upzt:"/dary/daRyxx/jyupzt",
          delete: "/dary/daRyxx/delete",
          deleteBatch: "/dary/daRyxx/deleteBatch",
          exportXlsUrl: "/dary/daRyxx/exportXls",
          importExcelUrl: "dary/daRyxx/importExcel",
          
        },
        dictOptions:{},
        superFieldList:[],
      }
    },
    created() {
      this.getSuperFieldList();
      setTimeout(() => {
        Watermark.set(store.getters.water , this.$refs.page)
        
      }, 1000);
    },
    computed: {
      importExcelUrl: function(){
        return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`;
      },
    },
    methods: {
      // searchReset(){
      //   this.queryParam.xm = '';
      //   this.queryParam.zt = '';
      //   this.queryParam.sfzh = '';
      //   this.queryParam.xb = '';
      //   this.queryParam.csrqks = '';
      //   this.queryParam.csrqjs = '';
      //   this.queryParam.mz = '';
      //   this.queryParam.twsjks = '';
      //   this.queryParam.twsjjs = '';
      //   this.queryParam.rwsjks = '';
      //   this.queryParam.rwsjjs = '';
      //   this.queryParam.zzmm = '';
      //   this.queryParam.lxdh = '';
      //   this.queryParam.xlqk = '';
      //   this.queryParam.jkzt = '';
      //   this.queryParam.cjxz = '';
      //   this.queryParam.bddh = '';
      //   this.queryParam.twzh = '';
      //   this.queryParam.azfs = '';
      //   this.queryParam.jl = '';
      //   this.queryParam.rwgxmc = '';
      //   let that = this;
      //   that.selectedRowKeys = [];
      //   that.selectUserIds = [];
      //   that.selectedDepIds = [];
      //   if (num !== 0) {
      //     that.queryParam = {};
      //     that.loadData(1);
      //   }z
      // },
      onCsrqChange(date, dateString){
        this.queryParam.csrqks = dateString[0];
        this.queryParam.csrqjs = dateString[1];  
      },
      onRwsjChange(date, dateString){
        this.queryParam.rwsjks = dateString[0];
        this.queryParam.rwsjjs = dateString[1];  
      },
      onTwsjChange(date, dateString){
        this.queryParam.twsjks = dateString[0];
        this.queryParam.twsjjs = dateString[1];  
      },
      handleDaAn(e){
        this.$router.push({ 
          name: 'dary-DaList', // 要跳转的组件名称 
          params: {  // 路由携带参数
            'xm': e.xm,
            'sfzh':e.sfzh,
            'id':e.id,
            'isZhanKai':'yes',
          }
        }); 
        
      },
      handleDaGd(e){
        let that = this;
        that.$confirm({
            title:"提示",
            content:"确认归档?",
            onOk: function(){ 
              httpAction(that.url.upzt+"?id="+e.id+"&zt=已归档",'','get').then((res)=>{ 
                  console.log("返回信息",res)
                  e.zt = "已归档";
                }).finally(() => { 
              })
            }
          });
      },
      initDictConfig(){
      },
      getSuperFieldList(){
        let fieldList=[];
        fieldList.push({type:'string',value:'xm',text:'姓名'})
        fieldList.push({type:'string',value:'sfzh',text:'身份证号'})
        fieldList.push({type:'string',value:'xb',text:'性别'})
        fieldList.push({type:'string',value:'csny',text:'出生年月'})
        fieldList.push({type:'string',value:'mz',text:'民族'})
        fieldList.push({type:'date',value:'rwsj',text:'入伍时间'})
        fieldList.push({type:'date',value:'twsj',text:'退伍时间'})
        fieldList.push({type:'string',value:'zzmm',text:'政治面貌'})
        fieldList.push({type:'date',value:'rdsj',text:'入党时间'})
        fieldList.push({type:'string',value:'lxdh',text:'联系电话'})
        fieldList.push({type:'string',value:'xlqk',text:'学历情况'})
        fieldList.push({type:'string',value:'nazd',text:'拟安置地'})
        fieldList.push({type:'string',value:'jkzt',text:'健康状态'})
        fieldList.push({type:'string',value:'cjxz',text:'残疾性质'})
        fieldList.push({type:'string',value:'rwd',text:'入伍地'})
        fieldList.push({type:'string',value:'bddh',text:'部队代号'})
        fieldList.push({type:'string',value:'twzh',text:'退伍证号'})
        fieldList.push({type:'string',value:'azfs',text:'安置方式'})
        fieldList.push({type:'string',value:'jl',text:'军龄'})
        fieldList.push({type:'string',value:'rwgxmc',text:'入伍高校名称'})
        fieldList.push({type:'string',value:'sffx',text:'是否复学'})
        fieldList.push({type:'string',value:'jlxx',text:'奖惩信息'})
        this.superFieldList = fieldList
      }
    }
  }
</script>
<style scoped>
  @import '~@assets/less/common.less';
  .ant-calendar-picker{
    width: 100%;
  }
</style>